package com.acheli.utils.math.angle;

public class ArcAngle implements AbstractAngle{ //弧度角
    private double arcNumber = 0F;
    private AbstractAngle upperLimit;
    private AbstractAngle lowerLimit;


    public ArcAngle(double arcNumber) {
        this.arcNumber = arcNumber;
    }

    @Override
    public void setUpperLimit(AbstractAngle upperLimit) {
        this.upperLimit = upperLimit;
    }

    @Override
    public void setLowerLimit(AbstractAngle lowerLimit) {
        this.lowerLimit = lowerLimit;
    }

    @Override
    public AbstractAngle getUpperLimit() {
        return this.upperLimit;
    }

    @Override
    public AbstractAngle getLowerLimit() {
        return this.lowerLimit;
    }

    public boolean upperThanLimit(AbstractAngle angle) {
        if (this.upperLimit != null){
            return angle.getArcAngleNum() > this.upperLimit.getArcAngleNum();
        }
        return false;
    }

    public boolean lowerThanLimit(AbstractAngle angle) {
        if (this.lowerLimit != null){
            return angle.getArcAngleNum() < this.lowerLimit.getArcAngleNum();
        }
        return false;
    }

    @Override
    public void setAngle(AbstractAngle angle) {
        if (lowerThanLimit(angle) || upperThanLimit(angle)){
            return;
        }
        this.arcNumber = angle.getArcAngleNum();
    }

    public void setAngleNum(double angleNum) {
        Angle angle = new Angle(angleNum);
        if (lowerThanLimit(angle) || upperThanLimit(angle)){
            return;
        }
        this.arcNumber = angleNum/180 *Math.PI;
    }
    public double getAngleNum() {
        return this.arcNumber * 180 / Math.PI;
    }

    public void setArcAngleNum(double arcAngleNum) {
        ArcAngle arcAngle = new ArcAngle(arcAngleNum);
        if (lowerThanLimit(arcAngle) || upperThanLimit(arcAngle)){
            return;
        }
        this.arcNumber = arcAngleNum;
    }

    public double getArcAngleNum() {
        return this.arcNumber;
    }

    @Override
    public void add(AbstractAngle otherAngle) {
        arcNumber += otherAngle.getArcAngleNum();
    }
}
